<?php

namespace app\common\model;

/**
 * [Gather  法会义工表]
 * @author [C。]
 * @return html
 */
class Gather extends Base
{
    protected $name = 'gather';
    /**
     * 根据搜索条件获取寺院列表信息
     */
    public function getlist($map,$from = 0, $size = 5)
    {
        $join = [
            ['app_company c','c.id = g.comid'],
        ];
        $order = ['g.id' => 'desc'];
        $result =  $this->field('g.id,g.title,g.cover,g.type,c.comname,g.maxnum,g.endtime,g.addtime,g.num,g.activetime,g.states,g.son_states')
            ->alias('g')
            ->join($join)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();
        return $result;
    }
    /**
     * 根据条件获取总数
     * @param array $param
     */
    public function getCount($map) {
        $join = [
            ['app_company c','c.id = g.comid'],
        ];
        $result =  $this
            ->alias('g')
            ->join($join)
            ->where($map)
            ->count();
        return $result;
    }
    /**
     * 根据条件获取
     * @param array $param
     */
    public function getWorker($map,$field='*',$from = 0, $size = 2) {
        $order = ['endtime'=>'desc','id' => 'desc'];
        $result =  $this->field($field)->where($map)->order($order)->limit($from,$size)->select();
        return $result;
    }
    /**
     * 根据条件获取总条数
     * @param array $param
     */
    public function getWorkerCount($map) {
        $result =  $this->where($map)->count();
        return $result;
    }
}